<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../plugins/jquery/dist/jquery.js"></script>
    <script src="../plugins/jquery/dist/qrcode.min.js"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script>
        var id = getUrlParam("id");
    </script>

</head>
<body>
<div id="qrCode">

</div>

<script>
    $(function () {
        alert(id);
        $.ajax({
            type:"GET",
            dataType:"json",
            url:"/pay/orderPay.do?oid="+id,  
            success:function(res){
               console.info(res);
                let qrCode=new QRCode('qrCode',res.data);
            }
        });
    });

</script>

<script>
    setInterval(function () {
        // 发送ajax请求
        let url = "/order/findState.do?oid="+id;
        $.post(url,function (resp) {
            console.info(resp);
            if(resp.flag){
                // 支付成功了
                location.href="pay_success.html";
            }else {
                location.href="pay_error.html";
            }
        })
    },60000);

    // 如果用户迟迟没有支付
    setTimeout(function () {
        location.href="pay_error.html";
    },60000);
</script>

</body>
</html>